<%@ include file="/en/jsp/static.jsp" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>
<%@ page import="linuxbox.todo.logic.BoxTodoCat" %>

<%
  int SYSTEMCAT = Integer.parseInt((String)request.getAttribute("SYSTEMCAT"));
  String str = (String)request.getAttribute("ENTRIES_PER_PAGE");
  int ENTRIES_PER_PAGE = 0;
  if (str!=null)
    ENTRIES_PER_PAGE = Integer.parseInt(str);

%>

<jsp:include page="/en/jsp/header.jsp" flush="true"/>

<script LANGUAGE="JavaScript">
function onAdd()
{
  var choice = document.theForm.CHOICE.value;
  if ( choice != null && choice.length > 0 )
  {
    var option = new Option(choice, choice);
    document.theForm.CATEGORIES.options[document.theForm.CATEGORIES.length] = option;
    document.theForm.CHOICE.value = "";
    document.theForm.CHOICE.focus();
  }
}

function onRemove()
{
  var options = document.theForm.CATEGORIES.options;
  if ( options.length > 0)
  {
    for (i=options.length-1; i >=0; i--)
    {
      if (options[i].selected == true)
        options[i] = null;
    }
  }
//	document.theForm.CATEGORIES.focus();
}

//select all the items so they will be sent out
function onSubmit()
{
//	alert("Set selected");
  var options = document.theForm.CATEGORIES.options;
  if ( options.length > 0)
  {
    for (i=options.length-1; i >=0; i--)
    {
      options[i].selected = true;
    }
//		alert("Set selected");
  }
}
</script>

<form action="<%=BoxStatic.servletDir%>BoxTodoSettingsAction" method=POST name=theForm >
  <table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
    <tr>
      <td>
        &nbsp;<img src="<%=BoxStatic.imageDir%>itemball.jpg" width=14 height=15 border=0 align="absmiddle">
        <b><%=boxName%> - Todo Settings</b>
      </td>
    </tr>
  </table>

<hr width=\"100%\" color=#E06000 align=left>

  <TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
<%
  if (SYSTEMCAT ==0)
  {
%>
    <tr><th align=left bgcolor="#7EC1F3" >
      <font size="+1">General:</font>
    </th></tr>
    <tr><td>
      Display
          <select name="ENTRIES_PER_PAGE" size="1" >
            <OPTION value=10 <% if (ENTRIES_PER_PAGE==10) out.print("selected");%>>10</OPTION>
            <OPTION value=20 <% if (ENTRIES_PER_PAGE==20) out.print("selected");%>>20</OPTION>
            <OPTION value=30 <% if (ENTRIES_PER_PAGE==30) out.print("selected");%>>30</OPTION>
            <OPTION value=50 <% if (ENTRIES_PER_PAGE==50) out.print("selected");%>>50</OPTION>
            <OPTION value=100 <% if (ENTRIES_PER_PAGE==100) out.print("selected");%>>100</OPTION>
            <OPTION value=200 <% if (ENTRIES_PER_PAGE==200) out.print("selected");%>>200</OPTION>
          </select>
         entries per page.
    </td></tr>
<%
  }
%>
    <tr><th align=left bgcolor="#7EC1F3">
      <font size="+1">Categories:</font>
    </th></tr>
    <tr><td>
      <input type=text name="CHOICE" size=40 maxlength=200>
      <input type="button" value="Add Category" name="Add" onclick="onAdd()">
    </td></tr>
    <tr><td>
      Current categories:   <input type="button" value="Remove Selected Choices" name="Remove" onclick="onRemove()">
    </td></tr>
    <tr><td>
      <select name="CATEGORIES" size="5" multiple>

<%
  String[] cats = null;
  if (SYSTEMCAT == 0)
  {
    cats = BoxTodoCat.getUserCategories(sec);
  }
  else
    cats = BoxTodoCat.getSystemCategories();

  if (cats!=null && cats.length >0)
  {
    for(int i=0; i< cats.length; i++)
    {
      out.print("<option value="+cats[i]+">"+cats[i]+"</option>");
    }
  }
%>
      </select>
    </td></tr>
    <tr><td>
      <input type=submit value="Save" onclick="onSubmit()" name=
      <%
        if (SYSTEMCAT == 0)
          out.print("SubmitSave");
        else
          out.print("SubmitSysSave");
      %>
      >
      <input type=submit value="Cancel" name=SubmitCancel>
    </td></tr>
  </table>

<hr width=\"100%\" color=#E06000 align=left>
</form>

<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
